<template>
  <div class="user-info-view">
    <el-card class="user-card">
      <div class="card-back">
        <el-link @click="goBack" :underline="false" class="back-link">
          <el-icon><ArrowLeft /></el-icon>
          返回
        </el-link>
      </div>
      <div class="user-header">
        <el-avatar :src="userImg" :size="120" />
        <div class="user-basic">
          <div class="user-name">{{ userStore.username || '未知用户' }}</div>
          <div class="user-email">{{ userStore.email || '未知邮箱' }}</div>
          <div class="user-id">ID：{{ userStore.id || '未知ID' }}</div>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { useUserStore } from '@/stores/user'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { ArrowLeft } from '@element-plus/icons-vue'

const userStore = useUserStore()
const defaultUserImg = 'https://cube.elemecdn.com/0/88/03b0d39563f48251a9ed908f818141.png'
const ImgURL = 'https://upload-bbs.miyoushe.com/upload/2023/09/27/26454523/3ff0274b8a39b4c82f56034615cf7c7b_2534397800130338630.jpg'
const userImg = ref(ImgURL || defaultUserImg)

const router = useRouter()
const goBack = () => {
  router.back()
}
</script>

<style scoped>
.user-info-view {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
  background: #f7f7f7;
}
.user-card {
  width: 520px;
  min-height: 320px;
  padding: 40px 32px 32px 32px;
  border-radius: 24px;
  box-shadow: 0 8px 32px rgba(209, 96, 83, 0.08);
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.card-back {
  position: absolute;
  left: 32px;
  top: 32px;
}
.back-link {
  color: #aaa;
  font-size: 16px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
  font-weight: 500;
}
.back-link .el-icon {
  margin-right: 4px;
  font-size: 18px;
}
.back-link:hover {
  color: #d16053;
}
.user-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 16px;
}
.user-basic {
  margin-top: 32px;
  text-align: center;
}
.user-name {
  font-size: 2rem;
  font-weight: bold;
  color: #d16053;
  margin-bottom: 12px;
}
.user-email {
  font-size: 1.2rem;
  color: #666;
  margin-bottom: 8px;
}
.user-id {
  font-size: 1rem;
  color: #aaa;
}
</style>
